package com.example.flashsales.service.impl;

import com.example.flashsales.entity.vo.GoodsInventoryVo;
import com.example.flashsales.entity.vo.GoodsVo;
import com.example.flashsales.mappers.GoodsInventoryMapper;
import com.example.flashsales.service.GoodsInventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsInventoryServiceImpl implements GoodsInventoryService {

    @Autowired
    GoodsInventoryMapper goodsInventoryMapper;

    @Autowired
    GoodsServiceImpl goodsService;

    /**
     * 增加一中商品
     * @param goodsId 商品id
     * @param count 数量
     * @return
     */
    @Override
    public boolean addGoods(long goodsId, double count) {
        final GoodsVo goodsVo = goodsService.viewGoodsMessage(goodsId);
        if (count <= 0.0){
            return false;
        }
        if (goodsVo == null){
            return false;
        }
        return goodsInventoryMapper.addGoods(goodsId, count) > 0;
    }

    /**
     * 修改商品库存
     * @param goodsId 商品id
     * @param count 修改的数量
     * @return
     */
    @Override
    public boolean updateCount(long goodsId, double count) {
        return false;
    }

    /**
     * 删除某种商品
     * @param goodsId
     * @return
     */
    @Override
    public boolean deleteGoods(long goodsId) {
        return goodsInventoryMapper.deleteGoods(goodsId) > 0;
    }


    /**
     * 查看所有商品库存
     * @return
     */
    @Override
    public List<GoodsInventoryVo> viewAllGoodsInventory() {
        return null;
    }


    /**
     * 查看某种商品的库存
     * @param goodsId
     * @return
     */
    @Override
    public GoodsInventoryVo viewGoodsInventory(long goodsId) {
        return null;
    }
}
